וַיַּֽעֲמֹ֥ד שָׂטָ֖ן עַל־יִשְׂרָאֵ֑ל וַיָּ֙סֶת֙ אֶת־דָּוִ֔יד לִמְנ֖וֹת אֶת־יִשְׂרָאֵֽל׃
און אַ שׂטן איז אױפֿגעשטאַנען אױף ישׂראל, און ער האָט אָנגערעדט דודן צו צײלן ישׂראל.
Rashi
Now Satan arose upon Israel Although this chapter is not complimentary to David, it was written here because it says at the end of the chapter that he built an altar and the Lord answered him from heaven. This is complimentary to David.